package com.jiuxian.scheduling.commons;

import com.jiuxian.scheduling.vo.LogInfoVO;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

/**
 * Created by wangjingqing on 2017/12/26.
 */
public class LogInfoContext {

    /** 错误信息列表*/
    private static List<LogInfoVO> errorList = new Vector<>();


    /**
     * 添加信息到列表中<br>
     * @param  logInfo LogInfoVO
     */
    public static void addLogInfo(LogInfoVO logInfo){
        if(!logInfo.getState()){
            errorList.add(logInfo);
        }
    }

    public static List<LogInfoVO> errorList(){
         List<LogInfoVO> reDate = new ArrayList<>();
         for (int i = 0;i < errorList.size(); i++){
            reDate.add(errorList.get(i));
            errorList.remove(i);
            i--;
         }
         return reDate;
    }

    public static List<LogInfoVO> errorList(int langth){
        List<LogInfoVO> reDate = new ArrayList<>();
        for (int i = 0;i < errorList.size(); i++){
            reDate.add(errorList.get(i));
            errorList.remove(i);
            i--;
            if(reDate.size() > langth){
                break;
            }
        }
        return reDate;
    }
}
